package com.wcl.demo.db;

import com.wcl.demo.model.entity.BackGroundData;
import com.wcl.demo.model.entity.BackGroundDataDao;

import java.util.List;

/**
 * Created by dllo on 15/11/30.
 */
public class BackGroundHelper {
    private DaoSingleton instance = DaoSingleton.getInstance();
    private BackGroundDataDao backGroundDataDao;

    public BackGroundHelper() {
        this.backGroundDataDao = instance.getBackGroundDataDao();
    }

    /**
     * 保存
     * @param backGroundDatas
     */
    public void saveBgInfor(List<BackGroundData> backGroundDatas){
        backGroundDataDao.insertInTx(backGroundDatas);
    }

    /***
     * 删除数据
     */
    public void deleteBg() {
        backGroundDataDao.deleteAll();
    }

    public List<BackGroundData> queryAll(){
        return backGroundDataDao.loadAll();
    }
    /**
     * 按自增长id查询
     */
    public List<BackGroundData> queryById(long id){
        List<BackGroundData> list=backGroundDataDao.queryBuilder().where(BackGroundDataDao.Properties.Bg_id_message.eq(id)).list();
        return list;
    }
}
